home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 240 (DVD) / Issue 240 - February 2008 - DPCS0208DVD.ISO / Extras / NetObjects Fusion / NOF10.exe / data1.cab / FSI / ControlPanel / lib / nof / controlpanel / html / ControlPanelWindow.js < prev    next >
Encoding:
Text File  |  2007-04-11  |  8.2 KB  |  224 lines

  1. /****i* SOURCE_FILE/INFO
  2. *
  3. * NAME
  4. *  ControlPanelWindow.js
  5. *
  6. * USAGE
  7. *  Part of Netobjects JavaScript Library.
  8. *
  9. * COPYRIGHT
  10. *  Copyright ⌐ 2002-2004 Website Pros, Inc.
  11. *  All Rights Reserved.
  12. *
  13. *  This is an unpublished work protected by Website Pros, Inc.
  14. *  as a trade secret, and is not to be used or disclosed except as
  15. *  expressly provided in a written license agreement executed by
  16. *  you and Website Pros, Inc.
  17. *
  18. *      <copyright@websitepros.com>
  19. *
  20. * NOTES
  21. *  JavaScript code.
  22. *****/
  23. if (!IS_isModuleInitialized("IS.NOF.CONTROLPANEL.HTML.ControlPanelWindow"))    
  24. {    
  25.     function NOF_ControlPanelWindow(_editedElement, _document, _name) {
  26.         this.__proto__ = NOF_ControlPanelWindow.prototype;
  27.         
  28.         if (arguments.length == 0 )
  29.             this.SUPER();
  30.         else {  
  31.             this.SUPER(_editedElement, _document, _name);
  32.         }
  33.         
  34.         this.defaultName = "ControlPanelWindow";
  35.         
  36.         this.Log = NOF.UTIL.LOGGING.getLogger("CPanelWindow");
  37.         //if (qLog.getHandlers().length && qLog.getHandlers()) {
  38.         this.Log.setLevel(NOF.UTIL.LOGGING.Level.CONFIG);
  39.         //this.Log.addHandler(new NOF.UTIL.LOGGING.ConsoleHandler(this.Log));
  40.         //}
  41.         
  42.     }
  43.     
  44.     NOF_ControlPanelWindow.inherits(NOF.HTML.EditorWindow);function NOF_ControlPanelWindowProtoBuilder() {
  45.         var member = NOF_ControlPanelWindow.prototype;
  46.         
  47.         member.onInit                     = onInit;
  48.         member.postRequest                = postRequest;
  49.         member.forward                     = forward;
  50.         member.windowLauncher             = windowLauncher;
  51.         member.initOfflineMode             = initOfflineMode;
  52.         member.doLoginFromOfflineMode     = doLoginFromOfflineMode;
  53.         member.doStartNewAccount         = doStartNewAccount;
  54.         member.doStartForgotPassword    = doStartForgotPassword;
  55.         member.displayOfflineCPPage        = displayOfflineCPPage;
  56.         member.loginAfterSignUp            = loginAfterSignUp;
  57.         
  58.         function onInit() {        
  59.             this.Log.info("ready to forward to " + this.editedElement.getOfflineURL(), this.defaultName, "onInit");
  60.             this.forward( this.editedElement.getOfflineURL() );        
  61.         }
  62.         
  63.         
  64.         function postRequest(url) {
  65.             //NOF.util_logging_ConsoleLogger_global.info("POST REQUEST = " + url)
  66.             try {        
  67.                 this.Log.info(url, "ControlPanelWindow", "postRequest");
  68.                 
  69.                 if ( parent.frames[1].document == null || !parent.frames[1].document )
  70.                     return;
  71.                 
  72.                 var statusDialog = new NOF.DIALOGS.StatusDlg();
  73.                 statusDialog.hide(); //this.getApp().getFSIApp2().SetShowStatusDialog(false);
  74.                 
  75.                 if(this.getDoc().getElementById("waitLayer"))
  76.                     this.getDoc().getElementById("waitLayer").style.visibility = "visible";
  77.                 
  78.                 var req = new NOF.NET.HttpRequest(url);
  79.                 req.setMethod("POST");                
  80.                 //req.setIncludeHeaderResult(false);
  81.                 //req.setIncludeBodyResult(true);                
  82.                 var httpObj = new NOF.NET.Http(req);
  83.                 var resp = httpObj.open();                
  84.                 var redirect = resp.getContent();                                
  85.                 req = null;
  86.                 httpObj = null;                
  87.                 //var redirect = this.getApp().getFSIApp2().HttpRequest2(url , '','', false, false, true);                
  88.                 
  89.                 this.Log.info(redirect, "ControlPanelWindow", "postRequest");
  90.                 //NOF.UTIL.LOGGING.getLogger("CPanelLog").info(redirect, "ControlPanelWindow", "postRequest");
  91.                 
  92.                 if(parent.frames[1].document.getElementById("waitLayer"))
  93.                     parent.frames[1].document.getElementById("waitLayer").style.visibility = "hidden";
  94.                 
  95.                 parent.frames[1].document.write(redirect);
  96.                 //statusDialog.hide(); //?
  97.                 statusDialog = null;
  98.             } catch(e){}
  99.             
  100.             
  101.         }
  102.         
  103.         
  104.         function forward(url) {
  105.             parent.frames[1].location = url;        
  106.         }
  107.         
  108.         
  109.         
  110.         function windowLauncher(url, width, height) {
  111.             width  = ( arguments.length > 1) ? width : 700;
  112.             height = ( arguments.length > 2) ? height : 650;
  113.             
  114.             NOF.DIALOGS.BrowserDlg.openBrowser(url, '', width, height, false);
  115.             //this.getApp().getFSIApp2().BrowserNoCtrl(url, '', width, height);
  116.         }
  117.         
  118.         
  119.         
  120.         function initOfflineMode() {
  121.             try {
  122.                 //NOF.util_logging_ConsoleLogger_global.info("Start INIT_OFFLINE_MODE")        
  123.                 this.getDoc().initialize(this);        
  124.                 this.getDoc().setElementValue("cp.offline.label.error.online", "");
  125.                 
  126.                 this.getDoc().getElementById("loginButton").disabled = true;
  127.                 if (this.getDoc().getElementById("signUp"))
  128.                     this.getDoc().getElementById("signUp").disabled = true;
  129.                 
  130.                 var autoLogin = NOF.App.getVariable("controlPanelAutoLogin"); //var autoLogin = this.getApp().getFSIApp().GetSystemVar("controlPanelAutoLogin");
  131.                 if (autoLogin == "")
  132.                     this.getDoc().getElementById("autoLogin").checked = true;
  133.                 else
  134.                     this.getDoc().getElementById("autoLogin").checked = autoLogin.toLowerCase() == "true";
  135.                 
  136.                 var onlineMode = this.editedElement.isOnline();    
  137.                 if( onlineMode == 0 ) {
  138.                     this.postRequest( this.editedElement.getOnlineURL() );
  139.                     //NOF.util_logging_ConsoleLogger_global.info("End ON_INIT - w/ POST_REQUEST")
  140.                     return;
  141.                 }
  142.                 if(this.getDoc().getElementById("waitLayer"))
  143.                     this.getDoc().getElementById("waitLayer").style.visibility = "hidden";            
  144.                 
  145.                 this.getDoc().getElementById("loginButton").disabled = false;
  146.                 if (this.getDoc().getElementById("signUp"))
  147.                     this.getDoc().getElementById("signUp").disabled = false;        
  148.                 
  149.             } catch (e) {
  150.                 return null;
  151.             }
  152.         }
  153.         
  154.         
  155.         
  156.         function doLoginFromOfflineMode(userName, password) {
  157.             var onLineMode = this.editedElement.isOnline();
  158.             this.Log.info("online mode = " + onLineMode + ". Start Login from Offline mode , username = "  + userName, "ControlPanelWindow", "postRequest");
  159.             //NOF.util_logging_ConsoleLogger_global.info("Start Login from Offline mode , username = "  + userName);
  160.             
  161.             var autoLogin = this.getDoc().getElementById("autoLogin").checked;
  162.             NOF.App.setVariable("controlPanelAutoLogin", autoLogin); //this.getApp().getFSIApp().SetSystemVar("controlPanelAutoLogin", autoLogin);
  163.             
  164.             if ( onLineMode == 0 ) {
  165.                 //this.displayOfflineCPPage();
  166.                 this.postRequest( this.editedElement.getOnlineURL(userName, password, false) );        
  167.             } else 
  168.                 this.displayOfflineCPPage();
  169.             
  170.             //NOF.util_logging_ConsoleLogger_global.info("End Login from Offline mode , username = "  + userName);
  171.         }
  172.         
  173.         function doStartNewAccount() {
  174.             var onLineMode = this.editedElement.isOnline();
  175.             
  176.             //NOF.util_logging_ConsoleLogger_global.info(this.defaultName + " New Account from Offline mode ");
  177.             
  178.             if ( onLineMode == 0 ) {
  179.                 this.getDoc().setElementValue("cp.offline.label.error.online", "");
  180.                 this.windowLauncher( this.editedElement.getOnlineNewAccountURL() );        
  181.                 
  182.                 //after new account is over try to launch online login
  183.                 this.onInit();
  184.             } else 
  185.                 this.displayOfflineCPPage();
  186.         }
  187.         
  188.         function doStartForgotPassword() {
  189.             var onLineMode = this.editedElement.isOnline();
  190.             
  191.             //NOF.util_logging_ConsoleLogger_global.info(this.defaultName + " Start 'Forgot Password' dialog from Offline mode ");
  192.             
  193.             if ( onLineMode == 0 ) {
  194.                 this.getDoc().setElementValue("cp.offline.label.error.online", "");
  195.                 this.windowLauncher( this.editedElement.getForgotPasswordURL() );
  196.                 this.getDoc().doc.getElementById("cp.offline.image.error.notOline").src = this.getResourceProperty("cp.offline.image.error.online");
  197.             } else
  198.             this.displayOfflineCPPage();
  199.         }
  200.         
  201.         function displayOfflineCPPage() {        
  202.             this.getDoc().setElementValue("cp.offline.label.error.online", this.getResourceProperty("cp.offline.label.error.online"));
  203.             this.getDoc().doc.getElementById("cp.offline.image.error.notOline").src = this.getResourceProperty("cp.offline.image.error.notOline");                
  204.         }
  205.         
  206.         function loginAfterSignUp() {                
  207.             /*
  208.             var nofReg = new NOF.NOFSettings();
  209.             var loc =  "file:///";
  210.             //loc += this.getApp().getFSIApp().GetRegistryString(true, "InstallPath");
  211.             loc += nofReg.get('InstallPath', NOF.NOFSettings.STRING_VALUE);
  212.             nofReg = null;
  213.             loc +="/NetObjects System/online/" + NOF.App.getDefaultLocale().getLanguage() + "/controlPanel/controlPanel_loginOffline.html";
  214.             //NOF.util_logging_ConsoleLogger_global.info("LOCATION = " + loc);
  215.             nofReg = null;
  216.             parent.frames[1].location = loc;
  217.             */
  218.             parent.frames[1].location = NOF.App.getSystemDirectory() + "/Online/" + NOF.App.getDefaultLocale().getLanguage() + "/controlPanel/controlPanel_loginOffline.html";
  219.         }
  220.     }
  221.     
  222.     NOF_ControlPanelWindowProtoBuilder();
  223.     NOF.CONTROLPANEL.HTML.__proto__.ControlPanelWindow = NOF_ControlPanelWindow;
  224. }